<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>本地存储</title>
</head>

<body>
  <div></div>
  <div class="box1"></div>
  <script>
    // 特点:本地存储只能存储字符串
    localStorage.setItem('uname', '伍广')
    const div = document.querySelector('div')
    const box1 = document.querySelector('.box1')
    div.innerHTML = localStorage.getItem('uname')

    console.log('===========存储对象=============');
    const obj = {
      name: '张三',
      age: 15,
      sex: 'man'
    }
    localStorage.setItem('obj', JSON.stringify(obj))
    box1.innerHTML = JSON.parse(localStorage.getItem('obj'))
  </script>
</body>

</html>